<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>javascript对象</h1>
    <h2>对象的语法</h2>
var 对象名={
    '属性名1'：'属性值1',
    方法名:function(){}
}
<h2>遍历对象</h2>
<p>for(变量名 in 对象名){
    对象名[变量名];
}</form></p>
<script>
let person={
    'name':'tom',
    'age':12,
    eat:function(){
        console.log(this.name+"吃饭");
    }
}
console.log(person);

//修改属性值
person['name']='jack';
person.age=15;
//调用方法
person.eat();

//遍历person对象
for(p in person){
console.log(person[p]);
}
</script>
</body>
</html>